
package com.huaweicloud.saaslanding.install.properties;

import static com.huaweicloud.saaslanding.install.constant.ModelConstant.DCS_PREFIX;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

/**
 * 功能描述
 *
 * @since 2022-07-14
 */
@EqualsAndHashCode
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
@Validated
@ConfigurationProperties(prefix = DCS_PREFIX)
public class Dcs {
    /**
     * Redis类型，cluster或single
     */
    @NotBlank(message = "Redis类型(dcs.type)不能为空")
    @Pattern(regexp = "cluster|single", message = "Redis类型(dcs.type)错误")
    private String type;

    /**
     * Redis节点
     */
    @NotBlank(message = "Redis节点(dcs.nodes)不能为空")
    private String nodes;

    /**
     * 服务端点
     */
    @NotBlank(message = "服务端点(dcs.endpoint)不能为空")
    private String endpoint;

    /**
     * 超时时间
     */
    @NotBlank(message = "超时时间(dcs.timeout)不能为空")
    private String timeout;

    /**
     * 密码
     */
    @NotBlank(message = "密码(dcs.password)不能为空")
    private String password;

    /**
     * 实例ID
     */
    @NotBlank(message = "实例ID(dcs.instance-id)不能为空")
    private String instanceId;

    /**
     * 实例名称
     */
    @NotBlank(message = "实例名称(dcs.instance-name)不能为空")
    @Pattern(regexp = "[a-z0-9]([-a-z0-9]*[a-z0-9])?", message = "实例名称由小写字母、数字、或字符“-”组成，并且必须以小写字母、数字开头和结尾，当前实例名称不符合要求")
    private String instanceName;
}
